#include "mainclass.h"
#include "stopthread.h"
#include <QApplication>
#include <QThread>
#include <QTimer>

void test1(int argc, char *argv[]) {
    QApplication a(argc, argv);
    MainClass mainClass;

    StopThread stopThread;
    QObject::connect(&stopThread, &StopThread::stop, &mainClass,
                     &MainClass::stop);

    QThread thread;
    QObject::connect(&thread, &QThread::started, &stopThread, &StopThread::start);
    stopThread.moveToThread(&thread);
    thread.start();

    emit mainClass.start();

    QThread::msleep(4000);

    if (thread.isRunning()) {
        qDebug()<<"thread.quit() start";
        thread.quit();
        thread.wait();
        qDebug()<<"thread.quit() end";
    }

    // a.exec();
}

int main(int argc, char *argv[]) {
    test1(argc, argv);
}
